//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tyr_menu\main.sqf"
#include <functions\core_macros.h>

if (isDedicated || !hasInterface) exitWith {};

[] spawn {
	TRACE("Start Waiting");
	waituntil { !isnull player };
	waituntil { player == player };
	waituntil { !isnull (findDisplay 46) };
	sleep 3;
	TRACE("Initializing");
	private "_ids";
	_ids = [];
	_ids set [count _ids,(findDisplay 46) displayAddEventHandler ["KeyDown", "_this call TYRMENU_fnc_keyDown"]];
	_ids set [count _ids,(findDisplay 46) displayAddEventHandler ["KeyUp", "_this call TYRMENU_fnc_keyUp"]];
	_ids set [count _ids,(findDisplay 46) displayAddEventHandler ["MouseZChanged", "_this call TYRMENU_fnc_MouseWheelRec"]];
	_ids set [count _ids,(findDisplay 46) displayAddEventHandler ["MouseButtonDown", "_this call TYRMENU_fnc_MouseClick"]];
	TRACE_1("Done",_ids);
	
	if (!isDedicated && !isnil "tyr_fnc_addHandler") then {
		["TYRMENU",
			[[
				localize "STR_TYR_MENU_TITLE"
				,{true}
				,{createDialog "TYR_MENU_config_ui";}
				,"tmf\core\modules\tyr_menu\tyrmenu.paa"
				,-1000
			]]
		] call tyr_fnc_addHandler;
	};
};